-
-
Notifications
You must be signed in to change notification settings - Fork 39
feat: fetch the tags and push each one individually #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fetch the tags and push each one individually #195
Conversation
🦋 Changeset detectedLatest commit: e9ef014 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
I've published a package and tested on our use case, |
@JounQin could you please take a look? 🙏 |
Sorry I didn't notice this PR previously, just raised some reviews. |
WalkthroughThis pull request adds a new changeset file that describes a minor feature for tag pushing and modifies the behavior of the publishing process. The changes update the evaluation of input flags using a centralized falsy values set, adjust the tag pushing control flow to allow individual tag pushes, and alter export declarations for several entities. Additionally, import statements and configuration details in workflows and package metadata have been updated. Changes
Sequence Diagram(s)sequenceDiagram
participant Runner as Publish Runner
participant RunModule as run.ts
participant GitUtils as git-utils.ts
participant GitLab as GitLab Server
Runner->>RunModule: runPublish(...)
RunModule->>RunModule: Determine "pushAllTags" based on package count and feature flag
alt pushAllTags is true
RunModule->>GitUtils: pushTags(all tags)
else pushAllTags is false
RunModule->>GitUtils: For each package, call pushTag(tag)
end
GitUtils->>GitLab: Execute git push command(s)
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/read-changeset-state.tsOops! Something went wrong! :( ESLint: 9.23.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js src/git-utils.tsOops! Something went wrong! :( ESLint: 9.23.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js src/utils.tsOops! Something went wrong! :( ESLint: 9.23.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/run.ts (1)
98-160
: 💡 Verification agent🧩 Analysis chain
Verify the tag format is consistent with changesets behavior.
The implementation assumes tag format is
packageName@version
, but for certain repository types, changesets might generate different formats. Please ensure consistency with how changesets generates its tags.
🌐 Web query:
How does changesets format its Git tags for single-package vs multi-package repositories?
💡 Result:
Changesets formats Git tags differently depending on whether they're used in single-package or multi-package repositories:
Single-package repositories
- Tags follow the format
vX.Y.Z
(e.g.,v1.2.3
)- Includes a "v" prefix before the semantic version[1][2][6]
Multi-package repositories
- Tags use
package-name@X.Y.Z
format (e.g.,utils@1.0.0
)- Combines the package name with its version number[2][6][8]
Repository Type Tag Format Example Single-package v1.2.3
Multi-package (monorepo) my-package@1.0.0
This distinction ensures clear version tracking in monorepos while maintaining conventional version tagging for standalone packages. The tags are automatically generated during the
changeset publish
command, and Changesets handles dependency-aware versioning in monorepos by:
- Updating interdependent package versions when needed[3][6]
- Creating separate tags for each modified package[5][10]
For both repository types, you must manually push tags using
git push --follow-tags
after publishing[2][8]. The version numbers themselves are determined frompackage.json
files, which Changesets updates during theversion
command[1][6].Citations:
- 1: https://brianschiller.com/blog/2023/09/18/changesets-vs-semantic-release/
- 2: https://github.com/changesets/changesets/blob/main/docs/command-line-options.md
- 3: https://dev.to/ramunarasinga-11/manage-your-versioning-and-changelogs-using-changesets-4big
- 4: https://insights.sei.cmu.edu/blog/versioning-with-git-tags-and-conventional-commits/
- 5: https://infinum.com/handbook/frontend/changesets
- 6: https://github.com/changesets/changesets/blob/main/packages/cli/README.md
- 7: https://www.jetbrains.com/help/rider/Tagging_Changesets.html
- 8: https://www.npmjs.com/package/@changesets/cli
- 9: https://changesets-docs.vercel.app/en/prereleases
- 10: https://lirantal.com/blog/introducing-changesets-simplify-project-versioning-with-semantic-releases
- 11: https://www.finalbuilder.com/forums/t/changesets-dont-detect-tag-changes-in-submodules/6676
- 12: https://github.com/changesets/changesets
- 13: changesets/changesets#972
Action: Align single-package tag format with Changesets behavior
In the single-package branch (
tool === 'root'
), the current code pushes tags in the formatpackageName@version
(e.g.,my-package@1.2.3
), while Changesets for single-package repositories generate tags with av
prefix (e.g.,v1.2.3
). This leads to inconsistency since the GitLab release call correctly usesv${pkg.packageJson.version}
. Please update the push tag logic in the single-package branch to use thevX.Y.Z
format.
- Change the tag pushed in the
tool === 'root'
branch to usev${pkg.packageJson.version}
.- Verify that the regex and tag-naming logic in the multi-package branch remain correct.
♻️ Duplicate comments (1)
src/run.ts (1)
120-124
: 💡 Verification agent🧩 Analysis chain
Consider using
v${pkg.packageJson.version}
for single-package repositories.For single package repositories, the tag should be only
vx.y.z
format instead ofpackageName@version
.
🏁 Script executed:
#!/bin/bash # Check if this is a single-package or multi-package repository # by looking at the package.json files in the repository echo "Checking repository structure..." # Count package.json files (excluding node_modules) PACKAGE_COUNT=$(find . -name "package.json" -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/build/*" | wc -l) echo "Found $PACKAGE_COUNT package.json files" # If it's just one, it's likely a single-package repo if [ "$PACKAGE_COUNT" -eq 1 ]; then echo "This appears to be a single-package repository" echo "For single-package repos, tag format should be 'vx.y.z' instead of 'packageName@version'" else echo "This appears to be a multi-package repository" echo "Current implementation using 'packageName@version' tag format is appropriate" fiLength of output: 588
Action Required: Update Tag Format for Single-Package Repository
Our repository verification confirms that there is only one
package.json
file, indicating a single-package repository. In such cases, the tag generated should follow thev<version>
format. Please update the tag insrc/run.ts
(Lines 120-124) accordingly. For example:-if (!pushAllTags) { - await gitUtils.pushTag( - `${pkg.packageJson.name}@${pkg.packageJson.version}`, - ) -} +if (!pushAllTags) { + await gitUtils.pushTag(`v${pkg.packageJson.version}`) +}
🧹 Nitpick comments (1)
src/run.ts (1)
154-160
: Use Promise.all for better performance when pushing multiple tags.When pushing multiple tags, using
Promise.all
would provide better performance by executing the pushes in parallel rather than sequentially.if (!pushAllTags) { - for (const pkg of releasedPackages) { - await gitUtils.pushTag( - `${pkg.packageJson.name}@${pkg.packageJson.version}`, - ) - } + await Promise.all( + releasedPackages.map(pkg => + gitUtils.pushTag(`${pkg.packageJson.name}@${pkg.packageJson.version}`) + ) + ) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/mighty-chefs-serve.md
(1 hunks)README.md
(1 hunks)src/gitUtils.ts
(1 hunks)src/main.ts
(1 hunks)src/run.ts
(5 hunks)
🔇 Additional comments (7)
.changeset/mighty-chefs-serve.md (1)
1-5
: LGTM! The changeset file is well-formatted.The changeset correctly specifies a minor version change for 'changesets-gitlab' with a clear description of the intended change: "fetch the tags and push each one individually".
src/gitUtils.ts (1)
33-35
: LGTM! Good addition of a focused utility function.The
pushTag
function follows the same pattern as other Git utility functions in this file, maintaining consistency in the codebase.README.md (1)
34-34
: Documentation is clear and well-linked to the issue.The new input parameter
INPUT_PUSH_ALL_TAGS
is well-documented with its type, default value, and purpose. Linking to the related issue (#194) provides additional context for users.src/run.ts (3)
63-63
: Interface update looks good.The
PublishOptions
interface has been correctly updated to include the new optional boolean parameterpushAllTags
.
86-86
: Function parameter update is correctly implemented.The
runPublish
function correctly includes the new parameter with a default value oftrue
, maintaining backward compatibility.
98-100
: Conditional tag pushing is properly implemented.The logic correctly checks the
pushAllTags
parameter before pushing all tags at once.src/main.ts (1)
91-91
: Good addition of the tag pushing control parameter.The new
pushAllTags
parameter allows for controlling whether to push all tags at once or individually, which directly addresses the GitLab limitation regarding the number of pipelines that can be triggered per Git push (as mentioned in issue #194).The default behavior is preserved by setting it to
true
unless explicitly set to 'false', maintaining backward compatibility.
f1eb12c
to
f146e08
Compare
commit: |
Hi @WeslleyNasRocha I'm going to merge and release this PR, is there anything special else other than this PR? I've changed to detect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/pkg-pr-new.yml (1)
30-30
: Update publish command with--compact
flagThe command now runs as
yarn dlx pkg-pr-new publish --compact
, which is intended to produce a more concise output during the publish process. Please confirm that:
- The
--compact
option is recognized by thepkg-pr-new
tool.- The behavior of the publishing step (including any tag pushing logic affected by this flag) remains correct as per the new PR objectives.
- Any documentation updates (e.g., related to
INPUT_PUSH_ALL_TAGS
and tag handling) are consistent with this change.Consider running a pipeline test to verify that the new flag does not cause unintended side effects.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pkg-pr-new.yml
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
|
@coderabbitai rull review |
@codecov-ai-reviewer review |
On it! We are reviewing the PR and will provide feedback shortly. |
🧩 Analysis chainI'll conduct a full review of this PR. Let me first gather more information about the code changes. 🏁 Script executed:
Length of output: 1973 I'll try a different approach to retrieve the PR changes: 🏁 Script executed:
Length of output: 32150 @JounQin I'll conduct a full review of this PR. 🏁 Script executed:
Length of output: 7644 @JounQin I've reviewed PR #195 "fix: fetch the tags and push each one individually" which addresses GitLab's pipeline limitation (issue #194). Key Changes
The changes are well-implemented and focused on solving the specific issue. The author already tested this in their environment with a published package. ✅ Actions performedReview triggered.
|
@coderabbitai summary |
✅ Actions performedSummary regeneration triggered. |
@coderabbitai Please, don't let me remind you again that you need to run |
Tip For best results, initiate chat on the files or code changes. @JounQin I sincerely apologize for the oversight. You're absolutely right - I should always run ✏️ Learnings added
|
This is to bypass the limitation of gitlab
Fix #194
Summary by CodeRabbit